package com.mszlu.news.controller;

import com.mszlu.news.service.CollectService;
import com.mszlu.news.vo.Result;
import com.mszlu.news.vo.params.CollectParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "收藏")
@RestController
@RequestMapping("collect")
public class CollectController {
    @Autowired
    private CollectService collectService;

    @ApiOperation(value = "通过用户id查找收藏过的文章详情")
    @PostMapping("list/{userId}")
    public Result listCollect(@PathVariable("userId") Long userId) {
        return collectService.listCollectByUserId(userId);
    }

    @ApiOperation(value = "增加收藏")
    @PostMapping("add")
    public Result addCollect(@RequestBody CollectParam collectParam){
        return collectService.addCollect(collectParam);
    }

    @ApiOperation(value = "删除收藏")
    @PostMapping("delete")
    public Result deleteCollect(@RequestBody CollectParam collectParam){
        return collectService.deleteCollect(collectParam);
    }

    @ApiOperation(value = "通过文章id查找收藏个数")
    @PostMapping("count/{articleId}")
    public Result CollectCounts(@PathVariable("articleId") Long articleId) {
        return collectService.CollectCounts(articleId);
    }
}
